

<!-- 我的积分 -->
<template>
	<view class="content">
		<view class="card">
			<view class="left">
				<view>
					<view class="price">{{userInfo.jf_num}}</view>
					<view class="detail">当前积分</view>
				</view>
			</view>
			<view class="right">
				<view>
					<view @click="toDetail">
						<view class="btn">交易明细</view>
					</view>
				</view>
			</view>
			<view class="sign">
				<view @click="sign">签到领积分</view>
			</view>
		</view>

		<view v-if="goodsList.length" class="title">
			<image src='/static/images/user/integral/jifenduihuan.png'></image>
			<view class="name">积分兑换</view>

			<view @click="gotoIntegralArea()" class="moreList-Container">
				<view class="more">更多</view>
				<image class="right" src="/static/images/user/integral/right.png"></image>
			</view>
		</view>
		<view v-if="goodsList.length" class="list">
			<goodList :list='goodsList'></goodList>
		</view>
	</view>
</template>

<script>
	import goodList from '@/components/goodList/goodList';

	export default {
		components: {
			goodList
		},
		data() {
			return {
				icon: {},
				goodsList: [],
				userInfo: {
					jf_num: '0'
				}
			};
		},
		onLoad() {
			this.getAreaGoodsList();
		},
		onShow() {
			let that = this;
			that.$api.globalUtil.requestAjax({
				url: '/AccountBalanceApi/findAccountBalanceByCustomerIdForApi',
				method: 'POST',
				data: {},
				success: function(res) {
					console.log(res.data.response.waterBalance);
					that.userInfo.jf_num = res.data.response.pointBalance;
				}
			});
		},
		methods: {
			// 签到
			sign() {
				let that = this;
				that.$api.globalUtil.requestAjax({
					url: '/CustomerApi/signInGivePoints',
					method: 'POST',
					success: function(res) {
						console.log(res.data.response.givingPoint);
						uni.navigateTo({
							url: '/pagesAccount/signIn/sign?point=' + res.data.response.givingPoint
						});
					}
				});
			},
			toDetail() {
				uni.navigateTo({
					url: '/pagesAccount/waterCoupon/detailed?type=jifen'
				});
			},


			//积分商品列表
			getAreaGoodsList() {

				var that = this;
				that.$api.globalUtil.requestAjax({
					url: '/GoodsApi/pointsAreaGoodsApi',
					method: "POST",
					data: {
						pageNum: 1, //页码
						pageSize: 10, //显示条数
						sort: null, //综合排序:null 销量排序:1 新品排序:2 价格ASC:3 价格DESC:4
						goodsCategoryThird: null
					},
					success: function(res) {
						if (res.data.success) {

							if (res.data.response.results.length) {
								that.goodsList = res.data.response.results;
								console.log(JSON.stringify(that.goodsList));
							} else {
								that.goodsList = [];
							}
						}
					}
				});
			},

			// 积分专区
			gotoIntegralArea() {
				uni.navigateTo({
					url: '/pagesGoods/specialArea/integralArea'
				});
			}
		}
	};
</script>

<style lang="less">
	page {
		background: #f5f5f5;
		height: 100%;
		// padding-left: 30rpx;
	}

	.content {
		margin: 0 auto;
		width: 690rpx;

		.card {
			margin-top: 34rpx;
			background-image: url(/static/images/user/integral/bg.png);
			width: 690rpx;
			height: 345rpx;
			background-size: cover;
			display: flex;
			flex-wrap: wrap;

			.left {
				width: 59.8%;
				height: 209rpx;
				display: flex;
				align-items: center;
				padding-left: 56rpx;

				.price {
					color: #000;
					font-weight: bold;
					font-size: 56rpx;
				}

				.detail {
					margin-top: 20rpx;
					color: #000;
					font-size: 26rpx;
				}
			}

			.right {
				width: 40%;
				height: 209rpx;
				display: flex;
				align-items: center;
				flex-direction: row-reverse;
				padding-right: 55rpx;

				.btn {
					color: white;
					font-size: 20rpx;
					width: 114rpx;
					height: 40rpx;
					background-color: #D21728;
					border-radius: 20rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					white-space: nowrap;
					margin-bottom: 18rpx;
				}
			}

			.sign {
				width: 100%;
				padding-left: 56rpx;

				view {
					color: white;
					font-size: 30rpx;
					background-image: linear-gradient(to right, #FF9C00, #FF7E00);
					width: 588rpx;
					height: 80rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					border-radius: 40rpx;
				}
			}
		}

		.title {
			display: flex;
			height: 40rpx;
			align-items: center;
			margin-top: 58rpx;

			image {
				height: 36rpx;
				width: 36rpx;
			}

			.name {
				font-size: 34rpx;
				color: #333;
				margin-left: 11rpx;
				font-weight: bold;
			}

			.more {
				color: #666666;
				font-size: 24rpx;
			}

			.right {
				width: 10rpx;
				height: 16rpx;
				margin-left: 12rpx;
			}
		}

		.list {
			margin-top: 30rpx;
			padding: 0 6rpx;
			width: 100%;
		}

		.moreList-Container {
			display: flex;
			align-items: center;
			margin-left: auto;
		}
	}
</style>



